package com.sali.b_design_pattern.g_singleton_pattern.lesson_singleton.b_lazy.a_synchron;

public class Singleton {

    private static Singleton instance;

    private Singleton() {
        // 私有构造⽅法，防⽌外部实例化
    }

    // 使⽤了同步关键字来确保线程安全, 可能会影响性能
    public static synchronized Singleton getInstance() {
        if (instance == null) {
            instance = new Singleton();
        }
        return instance;
    }

}
